package com.mapforge.filechooser;

import java.io.File;

import javax.swing.filechooser.FileFilter;

import com.mapforge.io.IOHandlerInterface;

public class IOHandlerFileFilter<T> extends FileFilter {
	private IOHandlerInterface<T> iohandler;
	private String description;

	public IOHandlerFileFilter(IOHandlerInterface<T> iohandler,
			String description) {
		this.iohandler = iohandler;
		this.description = description;
	}

	public void setIOHandler(IOHandlerInterface<T> iohandler) {
		this.iohandler = iohandler;
	}

	public IOHandlerInterface<T> getIOHandler() {
		return iohandler;
	}

	public boolean accept(File f) {
		return f.isDirectory() || iohandler.canLoad(f);
	}

	@Override
	public String getDescription() {
		return description;
	}

}
